home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10614 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: vyger712.nando.net!user
  2. From: armckenz@nando.net (Ashley mckenzie)
  3. Newsgroups: comp.lang.c
  4. Subject: borland 4.51 huge * struct problem
  5. Date: Tue, 19 Mar 1996 18:52:33 -0500
  6. Organization: Nando.net Public Access
  7. Message-ID: <armckenz-1903961852330001@vyger712.nando.net>
  8. NNTP-Posting-Host: vyger712.nando.net
  9.  
  10. I was wondering if anybody had encountered a similar problem:
  11.  
  12. Under Win3.1/95 when accessing a field in a struct pointed
  13. to by a huge pointer, the pointer will wrap around a 64k
  14. segment boundary if the struct straddles such a boundary.
  15.  
  16. ie
  17.  
  18. typedef struct Junk {
  19.   long a, b, c;
  20. } Junk;
  21.  
  22. foo()
  23. {
  24.   Junk huge *ptr;
  25.  
  26.   // assuming ptr is set up elsewhere
  27.  
  28.   ptr->b = 0;
  29. }
  30.  
  31. If ptr's pointer value looks like: 1234:fffe (in hex) with 1234 being the
  32. segment and fffe being the offset, accessing field b in the struct will
  33. not result in the right result. The compiler will wrap fffe to zero and
  34. not properly increment the segment register resulting in an address
  35. of 1234:0000.
  36.  
  37. Is there any way to correctly access the fields in a struct which straddles
  38. a segment border?
  39.  
  40. System: Borland 4.51 under Windows 3.1 and 95 using the large memory model
  41.         (16-bit compiler)
  42.  
  43. Thanks
  44.